package com.wuliupai.delivery.wuliupaidelivery.utils;

import android.content.Context;

import com.wuliupai.delivery.wuliupaidelivery.db.DBUtil_;
import com.wuliupai.delivery.wuliupaidelivery.db.ReadAssets;

/**
 * Class:
 * Created by KANG on 2016/11/28  13:45.
 * Email:khl8912@126.com
 */

public class CityUtil {
    private ReadAssets readAssets = new ReadAssets();
    private Context context;
    private DBUtil_ dbUtil;

    public CityUtil(Context context) {
        this.context = context;
        dbUtil = DBUtil_.getInstance_(context);
    }

    /**
     * 查找省名
     *
     * @param provinceCode 省码
     * @return 省名
     */
    public String findProvinceName(String provinceCode) {
        String provinceName = dbUtil.findProvinceByProvinceCode(readAssets.openDatabase(context),
                provinceCode).get(0).getCityName();
        return provinceName;
    }

    /**
     * 查找市名
     *
     * @param cityCode 市码
     * @return 市名
     */
    public String findCityName(String cityCode) {
        String cityeName = dbUtil.findCityByCityCode(readAssets.openDatabase(context),
                cityCode).get(0).getCityName();
        return cityeName;
    }

    /**
     * 查找县名
     *
     * @param areaCode 县码
     * @return 县名
     */
    public String findAreaName(String areaCode) {
        String areaName = dbUtil.findAreaByAreaCode(readAssets.openDatabase(context),
                areaCode).get(0).getCityName();
        return areaName;
    }
}
